import { onMounted, onUnmounted } from 'vue'

/**
 * useEventListener('mousemove', () => {})
 */
export function useEventListener(target, eventName, handler) {
  onMounted(() => {
    target.addEventListener(eventName, handler)
  })

  onUnmounted(() => {
    target.removeEventListener(eventName, handler)
  })
}
